'use strict';

module.exports = app => {
  const { INTEGER, STRING, DATE } = app.Sequelize;

  const Houses = app.model.define('houses', {
    id: {
      type: INTEGER,
      primaryKey: true,
      autoIncrement: true,
    },
    name: STRING(50),
    info: STRING(150),
    addres: STRING(200),
    price: INTEGER,
    cityCode: STRING,
    showCount: INTEGER,
    publishTime: {
      type: DATE,
    },
    startTime: {
      type: DATE,
    },
    endTime: {
      type: DATE,
    },
  });

  Houses.associate = () => {
    app.model.Houses.hasMany(app.model.Imgs, { foreignKey: 'houseId' });
  };

  return Houses;
};
